import React, { useState, useEffect } from 'react'



export default function index(WithComponent) {

  function NewComponent({ url, ...props }) {

    const [data, setData] = useState(null);

    useEffect(() => {
      const fetchData = async () => {
        setTimeout(() => {
          const jsonData = {
            name: '张三',
            age: 2
          }
          setData(jsonData);
        }, 3000)
      };
      fetchData();
    }, []);


    return (
      <div>
        <WithComponent data={data}
          isLoading={props.isLoading}
          {...props} />
      </div>
    )
  }


  return NewComponent
}
